if not SYSPATH then return end
-----------------------------------------
--公共聊天界面
-----------------------------------------
local zOrder    = 1000
local EditLen   = 26
local M  	= class("ChatView",PanelInner)
local model     = app.model("common")

function M:ctor(param)
	self._type = param
	self.class.super.ctor(self)
	self:initFromConfig(nil,"jcxj")
end

function M:onEnter()
	self.class.super.onEnter(self)
	self:init()
end

function M:onExit()
end

function M:init()
    local main = cc.CSLoader:createNode("zjh/res/SetLayer.csb")
    self:addChild(main,999)
    Adaptive(main).h()
    local function callBack(sender,eventType)
        if eventType == ccui.SliderEventType.percentChanged then
            local percentCount = sender:getPercent()
            percentCount = percentCount/100
            local aTag = sender:getTag()
            if aTag == 1 then     --背景音乐的音量设置
                AudioPlayer:setGameMusicVolume(percentCount)
            elseif aTag == 2 then --音效的音量设置
                AudioPlayer:setGameEffectVolume(percentCount)
            end
        end
    end 
    -- cc.uiloader:seekNodeByName(main, "main"):addTouchEventListener(function (obj,e)
    --     if e == ccui.TouchEventType.ended then
    --         --AudioPlayer:playGameSound("jcxj","btn")
    --         main:removeFromParent()
    --     end
    -- end)
    local music = cc.uiloader:seekNodeByName(main, "slider_yinyue")
    music:setTag(1)
    local sound = cc.uiloader:seekNodeByName(main, "slider_yinxiao")
    sound:setTag(2)
    music:addEventListener(function (sender, eventType) callBack(sender, eventType) end)
    sound:addEventListener(function (sender, eventType) callBack(sender, eventType) end)
    local effectPercent = AudioPlayer:getGameEffectVolume() * 100  --音效
    local musicPercent  = AudioPlayer:getGameMusicVolume() * 100   --音乐
    sound:setPercent(effectPercent)
    music:setPercent(musicPercent)    

    cc.uiloader:seekNodeByName(main, "btn_close"):addTouchEventListener(
        function(obj, e)
            if e == ccui.TouchEventType.ended then
                -- AudioPlayer:playGameSound("sgpk", "btn")
                main:removeFromParent()
                -- MVC.dismiss()
            end
        end
    )

    cc.uiloader:seekNodeByName(main, "btn_jiesanfj"):addTouchEventListener(
        function(obj, e)
            if e == ccui.TouchEventType.ended then
                -- AudioPlayer:playGameSound("sgpk", "btn")
                main:removeFromParent()
                MVC.dismiss()
            end
        end
    )

    cc.uiloader:seekNodeByName(main, "btn_gps"):addTouchEventListener(function (obj,e)   --GPS位置
    if e == ccui.TouchEventType.ended then
        -- AudioPlayer:playGameSound("sgpk","btn")
        game.view.csbShow("common.waringGps","zjh")
    end
    end)

end 

return M